package com.yylending.las.lending.quota.baseinfo;

import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yylending.las.Global;
import com.yylending.las.common.AESEntity;

import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

/**
 * M:实名认证
 * Created by ying_he on 2017/6/28.<br>
 * Copyright  2017 www.yylending.com. All Rights Reserved.<br><br>
 */

public class CustomerInfoModel extends Model {
    private static final String TAG = CustomerInfoModel.class.getSimpleName();
	public final static int METHOD_CUSTOMER_INFO = 1;

    @Override
    public Observable getObservable(Object params, int functionalCode) {
        Service service = (Service) NetworkHelper.createService(Service.class);
        return service.getCustomerInfo(Global.LOGIN_TOKEN, (AESEntity)params);
    }

    @Override
    public void onNext(Object entity) {
        CustomerInfoResult result = cast(entity);
        EventAgent.post(result);
    }

    private interface Service {
        @POST("server/customer/getInfo")
        Observable<CustomerInfoResult> getCustomerInfo(@Header("token") String token, @Body AESEntity emptyEntity);
    }

    static class CustomerInfoParams {
        /**
         * baseInfo: 基本信息; identity: 身份证; sface: 刷新信息; addInfo: 附加信息
         */
        public String type = "";
    }

    static class CustomerInfoResult extends BaseResultEntity<AesData> {
    }

    static class AesData {
        String json;
    }
}
